package com.atguigu.serviceedu.controller;


import com.atguigu.commonutils.R;
import com.atguigu.serviceedu.entity.subject.oneSubject;
import com.atguigu.serviceedu.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-07-08
 */
@RestController
@RequestMapping("/serviceedu/subject")
//@CrossOrigin//跨域
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类
    @PostMapping("addsubject")
    public R addSubject(MultipartFile file){
        //获取上传文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    //课程分类树形结构显示
    @GetMapping("findAllSubject")
    public R findAllSubject(){
        List<oneSubject> onesubject =  subjectService.getAllSubject();
        return R.ok().data("list",onesubject);
    }
}

